package bairui.international.controller.login.manager;

import com.sh_lianjing.spring.web.controller.enhance.output.bean.*;

/**
 *
 * @see bairui.international.controller.login.manager.Page_OutputInfo 信息
 *
 */
@SuppressWarnings("serial")
class Page_Output
{

	
	static public class Model
	 extends com.sh_lianjing.project.authority.model.domain.jpa.TB_LoginRecord
	{
	
		/**
		 * 构造函数
		 */
			@lombok.Getter @com.fasterxml.jackson.annotation.JsonIgnore
			private com.sh_lianjing.project.authority.model.domain.jpa.TB_LoginRecord _origin;
	
		public Model(
			com.sh_lianjing.project.authority.model.domain.jpa.TB_LoginRecord bean
		) {
			this._origin = bean;
			if(null != bean){
				this.setId(bean.getId());
				this.setAddr(bean.getAddr());
				this.setUser(bean.getUser());
				this.setCreateTime(bean.getCreateTime());
			}
		}
		
	
		/**
		 * 非继承属性
		 */
	
	
		/**
		 * json忽略注解覆盖继承属性
		 */
	
		/**
		 * 对象转字符串输出
		 */
	
		/**
		 * 相关类
		 */
	
	}
	

	/**
	 * ajax 列表输出数据
	 */	
	final static java.util.List<Model> output(
		java.util.List<com.sh_lianjing.project.authority.model.domain.jpa.TB_LoginRecord> content
	) {
		java.util.List<Model> newContent = new java.util.ArrayList<>();
		for(com.sh_lianjing.project.authority.model.domain.jpa.TB_LoginRecord bean : content){
			newContent.add(new Model(bean));
		}
		return newContent;
	}
	
	/**
	 * ajax 分页输出数据
	 */
	final static org.springframework.data.domain.Page<Model> output(
		org.springframework.data.domain.Page<com.sh_lianjing.project.authority.model.domain.jpa.TB_LoginRecord> page
	) throws Exception {
		return page.map(Model::new);
	}
	
	/**
	 * 分页
	 */
	final static org.springframework.data.domain.Pageable page(
		javax.servlet.http.HttpServletRequest request
	){
		// startPage @RequestParam(name="startPage", required=false, defaultValue="0") Integer startPage
		Integer startPage = 0;
		String startPagePara = request.getParameter("startPage");
		if(null != startPagePara){
			startPage = Integer.parseInt(startPagePara);
		}
		// pageSize @RequestParam(name="pageSize", required=false, defaultValue="10") Integer pageSize
		Integer pageSize = 10;
		String pageSizePara = request.getParameter("pageSize");
		if(null != pageSizePara){
			pageSize = Integer.parseInt(pageSizePara);
		}
		//
		return new org.springframework.data.domain.PageRequest(startPage, pageSize);
	}
	
	
	/**
	 * 排序扩展接口
	 */
	static interface OrderExtends {
		
	
		default org.springframework.data.domain.Sort sort(
			org.springframework.data.domain.Sort.Direction direction,
			com.querydsl.core.types.dsl.ComparableExpressionBase<?> ... sortBase
		){
			return com.sh_lianjing.spring.web.controller.enhance.output.order.util.Util_Order.sortTrans(direction, sortBase);
		}
	
		default com.querydsl.core.types.OrderSpecifier<?> order(
			org.springframework.data.domain.Sort.Direction direction,
			com.querydsl.core.types.dsl.ComparableExpressionBase<?> orderBase
		){
			return com.sh_lianjing.spring.web.controller.enhance.output.order.util.Util_Order.orderTrans(direction, orderBase);
		}
	}
	
	/**
	 * 排序
	 */
	final static org.springframework.data.domain.Sort sort(
		com.sh_lianjing.project.authority.model.domain.jpa.QTB_LoginRecord QRoot,
		javax.servlet.http.HttpServletRequest request
	){
		/*
		 * 排序属性
		 */
		// orderBy @RequestParam(name="orderBy", required=false, defaultValue="orderValue") String orderBy
		String orderByPara = request.getParameter(com.sh_lianjing.web.mySeparatePage.OrderInfo.OrderBy);
		if(null == orderByPara){
			orderByPara = "createTime";
		}
		// orderWay @RequestParam(name="orderWay", required=false, defaultValue="DESC") OrderWay orderWay
		String orderWayPara = request.getParameter(com.sh_lianjing.web.mySeparatePage.OrderInfo.OrderWay);
		if(null == orderWayPara){
			orderWayPara = "DESC";
		}
		org.springframework.data.domain.Sort.Direction direction = org.springframework.data.domain.Sort.Direction.valueOf(orderWayPara);
	
		//
		switch(orderByPara){
			case "addr":		return com.sh_lianjing.spring.web.controller.enhance.output.order.util.Util_Order.sortTrans(direction, QRoot.addr);
			case "user":		return com.sh_lianjing.spring.web.controller.enhance.output.order.util.Util_Order.sortTrans(direction, QRoot.user);
			case "createTime":		return com.sh_lianjing.spring.web.controller.enhance.output.order.util.Util_Order.sortTrans(direction, QRoot.createTime);
			default:
				throw new RuntimeException();
		}
	}
	
	
	

}

